package server

import (
	"context"
	"gitee.com/xfrm/middleware/xconfig"
	"gitee.com/xfrm/starter/boot/bootservice"
)

type ServConfType string

const (
	SERV ServConfType = "SERV"
	DB   ServConfType = "DB"
)

type Server interface {
	//eg: trade
	ServGroup(ctx context.Context) string
	//eg: points
	ServName(ctx context.Context) string
	//eg: trade/points
	ServLocation(ctx context.Context) string
	ServIp(ctx context.Context) string
	//e.g: 1
	Servid(ctx context.Context) int
	// eg: trade/points1
	Copyname(ctx context.Context) string
	// 启动服务
	Startup(ctx context.Context) error
	// 关停服务
	Shutdown(ctx context.Context) error
	// 添加关停回调函数
	AppendShutdownCallback(context.Context, func())
	// return true if server is local running
	IsLocalRunning(ctx context.Context) bool
	// is stopped
	IsStopped(ctx context.Context) bool
	// servinfos
	ServInfos(ctx context.Context) map[string]*bootservice.ServInfo
	ConfigCenter(ctx context.Context) xconfig.ConfigCenter
}
